
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>docker25 dockerFile_demo · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    
    <link rel="prev" href="docker24 SpringBoot 微服务打包Docker镜像.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="docker01 docker能干嘛.html">
            
                <a href="docker01 docker能干嘛.html">
            
                    
                    docker01 docker能干嘛
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="docker02 安装docker.html">
            
                <a href="docker02 安装docker.html">
            
                    
                    docker02 安装docker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="docker03 docker原理.html">
            
                <a href="docker03 docker原理.html">
            
                    
                    docker03 docker原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="docker04 镜像基本命令.html">
            
                <a href="docker04 镜像基本命令.html">
            
                    
                    docker04 镜像基本命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="docker05 容器基本命令.html">
            
                <a href="docker05 容器基本命令.html">
            
                    
                    docker05 容器基本命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="docker06 常用其他命令.html">
            
                <a href="docker06 常用其他命令.html">
            
                    
                    docker06 常用其他命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="docker07 进入当前正在运行的容器.html">
            
                <a href="docker07 进入当前正在运行的容器.html">
            
                    
                    docker07 进入当前正在运行的容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="docker08 部署nginx.html">
            
                <a href="docker08 部署nginx.html">
            
                    
                    docker08 部署nginx
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="docker09 部署tomcat.html">
            
                <a href="docker09 部署tomcat.html">
            
                    
                    docker09 部署tomcat
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="docker10 可视化面板.html">
            
                <a href="docker10 可视化面板.html">
            
                    
                    docker10 可视化面板
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="docker11 镜像原理.html">
            
                <a href="docker11 镜像原理.html">
            
                    
                    docker11 镜像原理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="docker12 commit镜像.html">
            
                <a href="docker12 commit镜像.html">
            
                    
                    docker12 commit镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="docker13 容器数据卷.html">
            
                <a href="docker13 容器数据卷.html">
            
                    
                    docker13 容器数据卷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="docker14 具名挂载和匿名挂载.html">
            
                <a href="docker14 具名挂载和匿名挂载.html">
            
                    
                    docker14 具名挂载和匿名挂载
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="docker15 初始dockerfile.html">
            
                <a href="docker15 初始dockerfile.html">
            
                    
                    docker15 初始dockerfile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="docker16 数据卷容器.html">
            
                <a href="docker16 数据卷容器.html">
            
                    
                    docker16 数据卷容器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="docker17 dockerFile.html">
            
                <a href="docker17 dockerFile.html">
            
                    
                    docker17 dockerFile
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="docker18 dockerFile基本命令.html">
            
                <a href="docker18 dockerFile基本命令.html">
            
                    
                    docker18 dockerFile基本命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="docker19 构建自己的centos.html">
            
                <a href="docker19 构建自己的centos.html">
            
                    
                    docker19 构建自己的centos
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="docker20 发布镜像.html">
            
                <a href="docker20 发布镜像.html">
            
                    
                    docker20 发布镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.22" data-path="docker21 网络详情.html">
            
                <a href="docker21 网络详情.html">
            
                    
                    docker21 网络详情
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.23" data-path="docker22 容器互联.html">
            
                <a href="docker22 容器互联.html">
            
                    
                    docker22 容器互联
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.24" data-path="docker23 自定义网络.html">
            
                <a href="docker23 自定义网络.html">
            
                    
                    docker23 自定义网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.25" data-path="docker24 SpringBoot 微服务打包Docker镜像.html">
            
                <a href="docker24 SpringBoot 微服务打包Docker镜像.html">
            
                    
                    docker24 SpringBoot 微服务打包Docker镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.26" data-path="docker25 dockerFile_demo.html">
            
                <a href="docker25 dockerFile_demo.html">
            
                    
                    docker25 dockerFile_demo
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >docker25 dockerFile_demo</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="dockerfile&#x7684;demo">dockerfile&#x7684;demo</h3>
<pre><code class="lang-bash"><span class="hljs-comment"># This dockerfile demo for project build to docker images</span>
<span class="hljs-comment"># VERSION 2</span>
<span class="hljs-comment"># Author: Shawn_xiao</span>
<span class="hljs-comment"># Command format: Instruction [arguments / command] &#x2026;</span>
<span class="hljs-comment"># 2018/10/10- firstversion: xiao</span>
<span class="hljs-comment"># 2018/10/11- chanege the tomcat version</span>

<span class="hljs-comment"># &#x7B2C;&#x4E00;&#x884C;&#x5FC5;&#x987B;&#x6307;&#x5B9A;&#x57FA;&#x7840;&#x5BB9;&#x5668;&#xFF0C;&#x5EFA;&#x8BAE;&#x4F7F;&#x7528;aipln&#x7C7B;&#x578B;&#x7684;&#x5C0F;&#x5BB9;&#x5668;</span>
FROM tomcat:8

<span class="hljs-comment"># &#x7EF4;&#x62A4;&#x8005;&#x4FE1;&#x606F;(&#x53EF;&#x9009;)</span>
MAINTAINER xiaojianjun xiaojianjun@tansun.com.cn

<span class="hljs-comment"># LABEL (&#x53EF;&#x9009;) &#x6807;&#x7B7E;&#x4FE1;&#x606F;(&#x81EA;&#x5B9A;&#x4E49;&#x4FE1;&#x606F;,&#x591A;&#x6807;&#x7B7E;&#x653E;&#x4E00;&#x884C;)</span>
LABEL app.maintainer=xiaojianjun
LABEL app.version=<span class="hljs-string">&quot;1.0&quot;</span> app.host=<span class="hljs-string">&apos;bestxiao.cn&apos;</span> description=<span class="hljs-string">&quot;&#x8FD9;&#x4E2A;app&#x4EA7;&#x54C1;&#x6784;&#x5EFA;&quot;</span>

<span class="hljs-comment"># ENV  (&#x53EF;&#x9009;)&#x73AF;&#x5883;&#x53D8;&#x91CF;(&#x6307;&#x5B9A;&#x4E00;&#x4E2A;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#xFF0C;&#x4F1A;&#x88AB;&#x540E;&#x7EED; RUN &#x6307;&#x4EE4;&#x4F7F;&#x7528;&#xFF0C;&#x5E76;&#x5728;&#x5BB9;&#x5668;&#x8FD0;&#x884C;&#x65F6;&#x4FDD;&#x6301; </span>
ENV JAVA_HOME /opt/java_jdk/bin
ENV PG_VERSION 9.3.4
ENV PATH /usr/<span class="hljs-built_in">local</span>/postgres-<span class="hljs-variable">$PG_MAJOR</span>/bin:<span class="hljs-variable">$PATH</span>

<span class="hljs-comment"># USER (&#x53EF;&#x9009;) &#x6307;&#x5B9A;&#x8FD0;&#x884C;&#x5BB9;&#x5668;&#x65F6;&#x7684;&#x7528;&#x6237;&#x540D;&#x6216; UID&#xFF0C;&#x540E;&#x7EED;&#x7684; RUN &#x4E5F;&#x4F1A;&#x4F7F;&#x7528;&#x6307;&#x5B9A;&#x7528;&#x6237;,&#x524D;&#x9762;&#x7684;RUN &#x4E0D;&#x53D7;&#x5F71;&#x54CD;</span>
<span class="hljs-comment"># RUN groupadd -r postgres &amp;&amp; useradd -r -g postgres postgres </span>
USER postgres

<span class="hljs-comment"># WORKDIT &#x540E;&#x7EED;&#x7684; RUN&#x3001;CMD&#x3001;ENTRYPOINT &#x6307;&#x4EE4;&#x914D;&#x7F6E;&#x5BB9;&#x5668;&#x5185;&#x7684;&#x5DE5;&#x4F5C;&#x76EE;&#x5F55;</span>
WORKDIR /path/to/workdir

<span class="hljs-comment"># ADD/COPY &#x5C06;&#x5916;&#x90E8;&#x6587;&#x4EF6;copy&#x5230;&#x5BB9;&#x5668;&#x4E2D;&#x3002;&#x533A;&#x522B;&#x662F;ADD&#x53EF;&#x4EE5;&#x4F7F;&#x7528;URL&#xFF0C;&#x8FD8;&#x53EF;&#x4EE5;&#x662F;tar</span>
<span class="hljs-comment"># COPY&#x53EA;&#x80FD;&#x4F7F;&#x7528;dockerfile&#x6240;&#x5728;&#x76EE;&#x5F55;</span>
<span class="hljs-comment"># ADD &lt;src&gt; &lt;dest&gt;</span>
<span class="hljs-comment"># COPY &lt;src&gt; &lt;dest&gt;</span>
COPY target/tomcat-release.war /usr/<span class="hljs-built_in">local</span>/tomcat/webapps/

<span class="hljs-comment"># RUN &#x955C;&#x50CF;&#x7684;&#x64CD;&#x4F5C;&#x6307;&#x4EE4;</span>
<span class="hljs-comment"># RUN &lt;command&gt; [&#x201C;executable&#x201D;, &#x201C;param1&#x201D;, &#x201C;param2&#x201D;]&#x3002;</span>
RUN <span class="hljs-built_in">echo</span> &#x201C;deb http://archive.ubuntu.com/ubuntu/ raring main universe&#x201D; &gt;&gt; /etc/apt/sources.list
RUN apt-get update &amp;&amp; apt-get install -y nginx
RUN mkdir /opt/deploy/
RUN <span class="hljs-built_in">echo</span> &#x201C;\ndaemon off;&#x201D; &gt;&gt; /etc/nginx/nginx.conf

<span class="hljs-comment"># EXPOSE &#x5BB9;&#x5668;&#x542F;&#x52A8;&#x540E;&#x9700;&#x8981;&#x66B4;&#x9732;&#x7684;&#x7AEF;&#x53E3;</span>
EXPOSE 22 80 8443 8080

<span class="hljs-comment"># VOLUME &#x672C;&#x5730;&#x6216;&#x5176;&#x4ED6;&#x5BB9;&#x5668;&#x6302;&#x8F7D;&#x7684;&#x6302;&#x8F7D;&#x70B9;&#xFF0C;&#x4E00;&#x822C;&#x7528;&#x6765;&#x5B58;&#x653E;&#x6570;&#x636E;&#x5E93;&#x548C;&#x9700;&#x8981;&#x4FDD;&#x6301;&#x7684;&#x6570;&#x636E;&#x7B49;&#x3002;</span>
<span class="hljs-comment">#VOLUME [&quot;/data&quot;]</span>
VOLUME [<span class="hljs-string">&quot;/data/postgres&quot;</span>, <span class="hljs-string">&quot;/other/path/&quot;</span>]


<span class="hljs-comment"># ENTRYPOINT  &#x5BB9;&#x5668;&#x542F;&#x52A8;&#x540E;&#x6267;&#x884C;&#x547D;&#x4EE4;&#xFF0C;&#x4E0D;&#x4F1A;&#x88AB;docker run&#x63D0;&#x4F9B;&#x7684;&#x53C2;&#x6570;&#x8986;&#x76D6;&#xFF0C;&#x53EA;&#x80FD;&#x6709;&#x4E00;&#x4E2A;ENTRYPOINT,</span>
<span class="hljs-comment"># &#x591A;&#x4E2A;ENTRYPOINT&#xFF0C;&#x4EE5;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x4E3A;&#x51C6;</span>
<span class="hljs-comment">#ENTRYPOINT [&#x201C;executable&#x201D;, &#x201C;param1&#x201D;, &#x201C;param2&#x201D;]</span>
<span class="hljs-comment">#ENTRYPOINT command param param2</span>
ENTRYPOINT <span class="hljs-built_in">echo</span> <span class="hljs-string">&quot;helloDocker&quot;</span>  

<span class="hljs-comment"># &#x5BB9;&#x5668;&#x542F;&#x52A8;&#x65F6;&#x6267;&#x884C;&#x6307;&#x4EE4;,&#x6BCF;&#x4E2A; Dockerfile &#x53EA;&#x80FD;&#x6709;&#x4E00;&#x6761; CMD &#x547D;&#x4EE4;</span>
<span class="hljs-comment">#CMD [&#x201C;executable&#x201D;, &#x201C;param1&#x201D;, &#x201C;param2&#x201D;] &#x4F7F;&#x7528; exec &#x6267;&#x884C;&#xFF0C;&#x63A8;&#x8350;&#x65B9;&#x5F0F;&#x3002;</span>
<span class="hljs-comment">#CMD command param1 param2 &#x5728; /bin/sh &#x4E2D;&#x6267;&#x884C;&#xFF0C;&#x63D0;&#x4F9B;&#x7ED9;&#x9700;&#x8981;&#x4EA4;&#x4E92;&#x7684;&#x5E94;&#x7528;&#x3002;</span>
<span class="hljs-comment">#CMD [&#x201C;param1&#x201D;, &#x201C;param2&#x201D;] &#x63D0;&#x4F9B;&#x7ED9; ENTRYPOINT &#x7684;&#x9ED8;&#x8BA4;&#x53C2;&#x6570;&#x3002;</span>
CMD /usr/sbin/nginx


<span class="hljs-comment"># ONBUILD &#x914D;&#x7F6E;&#x5F53;&#x6240;&#x521B;&#x5EFA;&#x7684;&#x955C;&#x50CF;&#x4F5C;&#x4E3A;&#x5176;&#x4ED6;&#x65B0;&#x521B;&#x5EFA;&#x955C;&#x50CF;&#x7684;&#x57FA;&#x7840;&#x955C;&#x50CF;&#x65F6;&#xFF0C;&#x6240;&#x6267;&#x884C;&#x7684;&#x64CD;&#x4F5C;&#x6307;&#x4EE4;&#x3002;&#x4F8B;&#x5982;&#xFF0C;Dockerfile &#x4F7F;&#x7528;&#x5982;&#x4E0B;&#x7684;&#x5185;&#x5BB9;&#x521B;&#x5EFA;&#x4E86;&#x955C;&#x50CF; image-A&#x3002;-- &#x5F88;&#x5C11;&#x4F7F;&#x7528;</span>

<span class="hljs-comment"># ONBUILD ADD . /app/src</span>
<span class="hljs-comment"># ONBUILD RUN /usr/local/bin/python-build &#x2013;dir /app/src</span>
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="docker24 SpringBoot 微服务打包Docker镜像.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: docker24 SpringBoot 微服务打包Docker镜像">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"docker25 dockerFile_demo","level":"1.26","depth":1,"previous":{"title":"docker24 SpringBoot 微服务打包Docker镜像","level":"1.25","depth":1,"path":"docker24 SpringBoot 微服务打包Docker镜像.md","ref":"docker24 SpringBoot 微服务打包Docker镜像.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"docker25 dockerFile_demo.md","mtime":"2021-04-17T06:21:12.832Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-04-17T07:50:48.567Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

